package com.scfire.util;
import java.util.Properties;

import javax.mail.Message.RecipientType;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class MailUtil {
	
	private static String userName = "zhangjian@adream.org"; 
	private static String password = "ZJ229100zj";  
	private static String host = "smtp.exmail.qq.com"; 
	private static String protocal = "smtp";
	//目标邮件地址
	private static String to = "xiatengfei@adream.org";   
	
    public void sendEmal(String text) throws Exception{  
        Properties props = new Properties();  
        props.put("mail.smtp.auth", "true");  
        Session session = Session.getDefaultInstance(props);  
        MimeMessage message = new MimeMessage(session);  
        message.setRecipients(RecipientType.TO, to);  
        message.setFrom(new InternetAddress(userName));  
        message.setSubject("火堆捐赠对账异常数据");  
        message.setText(text, "UTF-8");  
        Transport transport = session.getTransport(protocal);  
        transport.connect(host, userName, password);  
        transport.sendMessage(message, message.getAllRecipients());
    }
}
